#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2023/10/1 18:58
# @Author  : 孙俊
# @FileName: model.py
# @Software: PyCharm


from sqlalchemy import Column, Integer, String, Float, MetaData, Table
from sqlalchemy.ext.declarative import declarative_base

# 创建对象的基类
from db.curd import connect

Base = declarative_base()

# 用户数据模型
class User(Base):
    __tablename__ = 'user'
    id = Column(Integer, primary_key=True, index=True)
    username = Column(String)
    password = Column(String)



# # 数据总表模型
# class data(Base):
#     __tablename__= 'data'
#     id = Column(Integer, primary_key=True, index=True)
#     date = Column(String)
#     name = Column(String)
#     location = Column(String)
#     data1 = Column(Float)
#     data2 = Column(Float)
#     data3 = Column(Float)
#
#
#
#
#
# # 2. 创建SQLAlchemy引擎和连接
# # 这里以SQLite为例。如果你使用其他数据库，例如PostgreSQL或MySQL，更改连接字符串即可
# engine = connect.engine
#
# # 3. 如果test1表不存在，则创建它
# metadata = MetaData()
#
# if not engine.dialect.has_table(engine, "test1"):
#     columns = [Column(name, String) for name in data.columns]
#     test1 = Table('test1', metadata, *columns)
#     metadata.create_all(engine)
#
# # 4. 将数据导入test1表
# data.to_sql('test1', con=engine, index=False, if_exists='append')
#
# print("Data imported successfully!")


